# import os
# from fastapi import FastAPI
# from fastapi.middleware.trustedhost import TrustedHostMiddleware
# from fastapi.middleware.cors import CORSMiddleware
# from loguru import logger
# from config.main import server
#
# app = FastAPI()
# app.add_middleware(TrustedHostMiddleware, allowed_hosts=server.ALLOWED_HOSTS)
# app.add_middleware(CORSMiddleware, allow_origins=server.ALLOWED_ORIGINS, allow_credentials=server.ALLOWED_CREDENTIALS,
#                    allow_methods=server.ALLOWED_METHODS, allow_headers=server.ALLOWED_HEADERS)
# logger.add('logs/app.log', rotation='500 MB', compression='zip')
# # 获取当前脚本所在目录
# current_dir = os.path.dirname(os.path.abspath(__file__))
# # 动态添加路由
# for root, dirs, files in os.walk(current_dir):
#     for file in files:
#         # 如果文件名为views.py，则尝试导入router
#         if file == 'views.py':
#             try:
#                 module_path = os.path.join(root, file).replace('/', '.').replace('\\', '.')[:-3]
#                 path = module_path.split('.apps')[-1]  # 获取apps之后的路径
#                 module = __import__(f'apps{path}', fromlist=['router'])
#                 app.include_router(module.router)
#             except:
#                 pass
